/* 
 *  <copyright file="RectangleBodyCmp.cs" company="Wesley Jowitt">
 *  
 *  SobrietyEngine: Copyright (c) 2011 Wesley Jowitt
 *  
 *  This software is distributed under a software license.
 *   * As of the creation time of this file, the license in use is the Microsoft Permissive License (Ms-PL) 
 *    * The license can be viewed at:
 *     * License.Txt in the root folder of this project
 *      * http://sobrietyengine.codeplex.com/license
 *       * http://www.microsoft.com/opensource/licenses.mspx
 *       
 *  </copyright>
 *   */

using System;
using FarseerPhysics.Dynamics;
using FarseerPhysics.Factories;
using Microsoft.Xna.Framework;



namespace SobrietyEngine.Components.Physics
{
    public class RectangleBodyCmp:FarseerPhysicsCmp, SobrietyEngine.Components.IComponent
    {
        Vector2 size;

        public RectangleBodyCmp()
            : base()
        {                       
        }

        public RectangleBodyCmp(String _worldName, Vector2 _size)
            : base(_worldName)
        {
            size = _size;
        }

         override public Boolean InitComponent()
        {            
            //use the body factory to create the physics body
            physicsGameService = Actor.GameServices().PhysicsGameService;
            world = physicsGameService.Worlds[physicsWorldName];

            Body = BodyFactory.CreateRectangle(world, size.X, size.Y, Mass);

            base.InitComponent();

            //Body.Position = position.Get()* Scale;
            //Body.IgnoreGravity = IgnoreGravity;
            Body.Enabled = enabled;
            //TODO: body.LinearDragCoefficient = linearDragCoefficient;
            //Body.LinearDamping = linearDragCoefficient;
            
            //if (momentOfInertia != 0)
                //TODO: body.MomentOfInertia = momentOfInertia;

            return true;
        } 
    }
}
